Overview
OpenCLIP provides extensive configuration options for training CLIP models. This page documents all important training flags and hyperparameters fromparams.py.
To see all available options:
Data Configuration
Training Data
string
Path to training data. For WebDataset, use glob patterns like
/data/train-{0000..2175}.tar. Multiple sources can be combined with ::.string
Path to validation data (same format as train-data).
integer
Total number of samples in training dataset. Required for WebDataset.
integer
Number of samples in validation dataset.
string
default:"auto"
Dataset format:
webdataset, csv, synthetic, or auto (auto-detect).boolean
Enable sampling with replacement for webdataset. Recommended for large datasets and multiple data sources.
CSV Data Parameters
string
default:"\\t"
Column separator for CSV files (tab by default).
string
default:"filepath"
Column name for image paths in CSV.
string
default:"title"
Column name for captions in CSV.
Data Upsampling
string
Upsampling factors for multiple data sources, separated by
::. Controls relative sampling probability.Model Configuration
Model Selection
string
default:"RN50"
Model architecture to train. See Model Architectures for all options.
string
Load pretrained weights. Can be a tag (e.g.,
laion2b_s34b_b79k) or a local path.boolean
Load ImageNet pretrained weights for the image encoder (if available).
Model Modifications
integer
Override default image input size.
integer
Override default text context length.
float
Override patch dropout probability for ViT models. Use 0.5-0.75 for 2-3x speedup.
boolean
Force QuickGELU activation (for compatibility with older checkpoints).
boolean
Force separate text tower (CustomTextCLIP architecture).
Training Hyperparameters
Batch Size and Epochs
integer
default:"64"
Batch size per GPU. Total batch size = batch_size × num_gpus × accum_freq.
integer
default:"32"
Number of training epochs.
integer
default:"1"
Gradient accumulation frequency. Simulates larger batch sizes.
Learning Rate
float
Learning rate. Default depends on model:
- ViT models: 5e-4
- ResNet models: 5e-4
integer
default:"10000"
Number of warmup steps (linear warmup from 0 to lr).
string
default:"cosine"
Learning rate schedule:
cosine, const, or const-cooldown.integer
Number of cooldown epochs for
const-cooldown scheduler.float
default:"0.0"
End learning rate for cooldown.
float
default:"1.0"
Power for polynomial cooldown (1.0 = linear).
Optimizer
string
default:"adamw"
Optimizer choice. Use
adamw or timm/{optimizer} for timm optimizers.float
Adam beta1 parameter. Default:
- ViT: 0.9
- ResNet: 0.9
float
Adam beta2 parameter. Default:
- ViT: 0.98
- ResNet: 0.999
float
Adam epsilon parameter. Default:
- ViT: 1e-6
- ResNet: 1e-8
float
default:"0.2"
Weight decay (L2 regularization).
float
Momentum for timm optimizers (SGD, etc.).
Gradient Clipping
float
Gradient clipping norm. Prevents gradient explosion.
Precision and Memory
Precision
string
default:"amp"
Training precision:
amp, amp_bf16, bf16, fp16, fp32.Memory Optimization
boolean
Enable gradient checkpointing to reduce memory usage (slower training).
boolean
Calculate loss with local features @ global (reduces memory from O(n²) to O(n)).
boolean
Enable gradient flow through feature gathering (use with —local-loss).
Data Loading
integer
default:"4"
Number of data loading workers per GPU.
Image Preprocessing
float[]
Override image normalization mean (RGB).
float[]
Override image normalization std (RGB).
string
Image resize interpolation:
bicubic, bilinear, or random.string
Image resize mode:
shortest, longest, or squash (inference only).key=value
Data augmentation configuration (key-value pairs).
Model Locking (Transfer Learning)
Image Tower
boolean
Lock (freeze) entire image encoder.
integer
default:"0"
Leave last N image tower layer groups unlocked.
boolean
Freeze BatchNorm running statistics in locked layers.
Text Tower
boolean
Lock (freeze) entire text encoder.
integer
default:"0"
Leave last N text tower layers unlocked.
boolean
Freeze LayerNorm in locked text layers.
Checkpointing and Logging
Checkpoints
integer
default:"1"
Save checkpoint every N epochs.
boolean
Save most recent checkpoint as
epoch_latest.pt.boolean
Delete previous checkpoint after saving new one (saves disk space).
string
Resume training from checkpoint path or “latest”.
Logging
string
default:"./logs/"
Directory for logs and checkpoints.
string
Experiment name (defaults to auto-generated based on timestamp and config).
string
Logging backends:
tensorboard, wandb, or tensorboard,wandb.integer
default:"100"
Log training metrics every N steps.
Weights & Biases
string
default:"open-clip"
W&B project name.
string
Notes for W&B run.
Evaluation
string
Path to ImageNet validation set for zero-shot evaluation during training.
string
Path to ImageNet-v2 for additional zero-shot evaluation.
integer
default:"2"
Run zero-shot evaluation every N epochs.
integer
default:"1"
Run validation every N epochs.
CoCa-Specific Parameters
float
default:"1.0"
Weight for CoCa contrastive loss.
float
default:"2.0"
Weight for CoCa caption generation loss.
Distributed Training
string
URL for distributed training initialization.
string
Distributed backend:
nccl (NVIDIA GPU), hccl (Ascend NPU), or gloo (CPU).boolean
Use Horovod for distributed training.
boolean
Enable static graph optimization for DDP (PyTorch >= 1.11).
boolean
Use synchronized batch normalization across GPUs.
Advanced Options
Compilation
boolean
Compile model with torch.compile() (PyTorch >= 2.0).
boolean
TorchScript the model.
boolean
Trace model with torch.jit.trace (inference only).
Model Distillation
string
Teacher model architecture for distillation.
string
Teacher model pretrained weights.
Loss Configuration
boolean
Use SigLip (sigmoid) loss instead of standard CLIP loss.
string
Distributed loss implementation override.
Remote Syncing
string
Remote path to sync checkpoints (S3 bucket or filesystem).
integer
default:"300"
Sync to remote every N seconds.
string
default:"s3"
Protocol for remote sync:
s3 or fsspec.Experimental
string
Use bitsandbytes linear layers for int8 training (experimental).
Other
integer
default:"0"
Random seed for reproducibility.
string
default:"cuda"
Device for training:
cuda or cpu.string
Override default cache directory for model/tokenizer downloads.
boolean
Enable debug logging.
boolean
Log on local master (each node) instead of global master only.
boolean
Copy entire codebase to log directory.
Example Configurations
Small-Scale Training (RN50 on CC3M)
Medium-Scale Training (ViT-B/32 on CC12M)
Large-Scale Training (ViT-L/14 on LAION-400M)
Recommended Settings by Model
ViT-B/32
ViT-L/14
RN50
Next Steps
Single-Node Training
Apply these configurations to single-node training
Distributed Training
Configure distributed training optimizations
Data Preparation
Configure data loading and preprocessing
Fine-tuning
Configure fine-tuning from pretrained models
